﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Teacher/Teacher.master" AutoEventWireup="true" CodeFile="ManageCompetition.aspx.cs" Inherits="Teacher_ManageTeacher" %><%@ Register assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">

    <script type="text/javascript">
        function OnLinkClick(id, visibleIndex) {
            if (confirm('Do you wish to delete row with ID = ' + id + '?'))
                gvwCompetition.DeleteRow(visibleIndex);
        }       
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <dx:ASPxGridView ID="gvwCompetition" runat="server" AutoGenerateColumns="False" 
        CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx" 
        DataSourceID="SqlDataSource1" KeyFieldName="CompetitionID" 
        Caption="Competition Management" Width="100%" 
        ClientInstanceName="gvwCompetition" 
        onrowvalidating="gvwCompetition_RowValidating">
        <Columns>
            <dx:GridViewDataTextColumn Caption="Delete" VisibleIndex="2" ReadOnly="True">
                <EditFormSettings Visible="False" />
                <DataItemTemplate>
                    <a ID="DeleteButton" href="javascript:OnLinkClick(<%# Container.KeyValue.ToString()%>, <%# Container.VisibleIndex.ToString()%>);">Delete</a>
                </DataItemTemplate>
            </dx:GridViewDataTextColumn>
            <dx:GridViewCommandColumn VisibleIndex="0" Caption="New">
                <NewButton Visible="True">
                </NewButton>
            </dx:GridViewCommandColumn>
            <dx:GridViewCommandColumn ShowInCustomizationForm="True" VisibleIndex="1" 
                Caption="Edit">
                <EditButton Visible="True">
                </EditButton>
                <UpdateButton Text="Save">
                </UpdateButton>
                <ClearFilterButton Visible="True">
                </ClearFilterButton>
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="Competition_Name" VisibleIndex="3">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataMemoColumn FieldName="Competition_Detail" VisibleIndex="4">
                <PropertiesMemoEdit Height="150px" Width="500px">
                </PropertiesMemoEdit>
                <EditFormSettings ColumnSpan="2" RowSpan="1" />
            </dx:GridViewDataMemoColumn>
            <dx:GridViewDataDateColumn FieldName="Start_Date" VisibleIndex="5" 
                Caption="Start Date">
            </dx:GridViewDataDateColumn>
            <dx:GridViewDataDateColumn FieldName="End_Date" VisibleIndex="6" 
                Caption="End Date">
            </dx:GridViewDataDateColumn>
            <dx:GridViewDataComboBoxColumn FieldName="ClassID" VisibleIndex="7" 
                Caption="Class">
                <PropertiesComboBox DataSourceID="SqlDataSource2" TextField="ClassID" 
                    ValueField="ClassID">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataComboBoxColumn FieldName="CourseID" VisibleIndex="9" 
                Caption="Course">
                <PropertiesComboBox DataSourceID="SqlDataSource3" TextField="CourseID" 
                    ValueField="CourseID">
                    <Columns>
                        <dx:ListBoxColumn FieldName="CourseID" Name="Course ID" />
                        <dx:ListBoxColumn FieldName="Course_Name" Name="Course Name" />
                    </Columns>
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
        </Columns>
        <Settings ShowFilterRow="True" />
        <Images SpriteCssFilePath="~/App_Themes/DevEx/{0}/sprite.css">
            <LoadingPanelOnStatusBar Url="~/App_Themes/DevEx/GridView/StatusBarLoading.gif">
            </LoadingPanelOnStatusBar>
            <LoadingPanel Url="~/App_Themes/DevEx/GridView/Loading.gif">
            </LoadingPanel>
        </Images>
        <ImagesFilterControl>
            <LoadingPanel Url="~/App_Themes/DevEx/GridView/Loading.gif">
            </LoadingPanel>
        </ImagesFilterControl>
        <Styles CssFilePath="~/App_Themes/DevEx/{0}/styles.css" CssPostfix="DevEx">
            <Header ImageSpacing="5px" SortingImageSpacing="5px">
            </Header>
            <LoadingPanel ImageSpacing="5px">
            </LoadingPanel>
        </Styles>
        <StylesEditors ButtonEditCellSpacing="0">
            <ProgressBar Height="21px">
            </ProgressBar>
        </StylesEditors>
    </dx:ASPxGridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Institte_of_Fine_ArtsConnectionString %>" 
        DeleteCommand="UPDATE Competition SET Xoa= 'True' WHERE CompetitionID = @CompetitionID" 
        InsertCommand="INSERT INTO [Competition] ([Competition_Name], [Competition_Detail], [Start_Date], [End_Date], [StaffID], [ClassID], [CourseID], [Xoa]) VALUES (@Competition_Name, @Competition_Detail, @Start_Date, @End_Date, @StaffID, @ClassID, @CourseID, @Xoa)" 
        SelectCommand="SELECT * FROM [Competition] WHERE Xoa = 'False'" 
        
        UpdateCommand="UPDATE [Competition] SET [Competition_Name] = @Competition_Name, [Competition_Detail] = @Competition_Detail, [Start_Date] = @Start_Date, [End_Date] = @End_Date, [StaffID] = @StaffID, [ClassID] = @ClassID, [CourseID] = @CourseID WHERE [CompetitionID] = @CompetitionID">
        <DeleteParameters>
            <asp:Parameter Name="CompetitionID" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Competition_Name" Type="String" />
            <asp:Parameter Name="Competition_Detail" Type="String" />
            <asp:Parameter Name="Start_Date" Type="DateTime" />
            <asp:Parameter Name="End_Date" Type="DateTime" />
            <asp:SessionParameter Name="StaffID" SessionField="Teacher" Type="String" />
            <asp:Parameter Name="ClassID" Type="String" />
            <asp:Parameter Name="CourseID" Type="String" DefaultValue="" />
            <asp:Parameter DefaultValue="False" Name="Xoa" />
            <asp:Parameter DefaultValue="cat" Name="key" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Competition_Name" Type="String" />
            <asp:Parameter Name="Competition_Detail" Type="String" />
            <asp:Parameter Name="Start_Date" Type="DateTime" />
            <asp:Parameter Name="End_Date" Type="DateTime" />
            <asp:SessionParameter DefaultValue="" Name="StaffID" SessionField="Teacher" 
                Type="String" />
            <asp:Parameter Name="ClassID" Type="String" />
            <asp:Parameter Name="CourseID" Type="String" />
            <asp:Parameter Name="CompetitionID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Institte_of_Fine_ArtsConnectionString %>" 
        SelectCommand="SELECT [ClassID] FROM [Class]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Institte_of_Fine_ArtsConnectionString %>" 
        SelectCommand="SELECT [CourseID], [Course_Name] FROM [Course]"></asp:SqlDataSource>
</asp:Content>

